/**对表情转义**/
export const emojiEncode = (e) => {
    let n = /[\ud800-\udbff][\udc00-\udfff]/g;
    // let n
    // 检测utf16字符正则
    return e = e.replace(n, function (e) {
        let n, r;
        return 2 === e.length ? (n = e.charCodeAt(0), r = e.charCodeAt(1),
            "&#" + (1024 * (n - 55296) + 65536 + r - 56320) + ";") : e
    })
}

export const emojiDecode = (e) => {
    if(!e) return null
    let n = /&#.*?;/g; //获取数据库种16进制的数据
    //然后进行解码操作
    return e.replace(n, function (e) {
        let n, r, t;
        return 9 == e.length ? (t = parseInt(e.match(/[0-9]+/g)), n = Math.floor((t - 65536) / 1024) +
            55296, r = (t - 65536) % 1024 + 56320, unescape("%u" + n.toString(16) + "%u" + r
                .toString(16))) : e
    })
}